<?php

namespace App\Model;

use Hyperf\Database\Model\Builder;
use Hyperf\DbConnection\Model\Model;

class AdolescentPassword extends Model
{
    protected $table = 'adolescent_password';

    public $timestamps = false;

    /**
     * 确认是否开启
     * @param $userId
     * @return int
     */
    public function checkIsPassword($userId): int
    {
        return self::where('user_id', $userId)->count() ?? 0;
    }

    /**
     * 根据用户id获取青少年信息
     * @param $userId
     * @return Builder|\Hyperf\Database\Model\Model|object|null
     */
    public function getInfoByUserId($userId)
    {
        return self::where('user_id', $userId)->first();
    }
}